package com.betterjr.modules.commissionbankcode;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.dubbo.config.annotation.Reference;
import com.betterjr.common.web.ControllerExceptionHandler;
import com.betterjr.common.web.ControllerExceptionHandler.ExceptionHandler;
import com.betterjr.common.web.Servlets;
import com.betterjr.modules.commissionfile.CommissionInvoiceController;
import com.betterjr.modules.commissionfile.ICommissionPayBankCode;

/**
 * 
 * @ClassName: CommissionBankCodeController 
 * @Description: TODO(直通车代码控制层) 
 * @author chenlq
 * @date 2017年10月17日 上午11:43:52 
 *
 */
@Controller
@RequestMapping(value = "/Scf/CommissionPay")
public class CommissionBankCodeController {

    private static final Logger logger = LoggerFactory.getLogger(CommissionInvoiceController.class);
    @Reference(interfaceClass = ICommissionPayBankCode.class)
    private ICommissionPayBankCode commissionPayBankCode;

    /**
     * 支付直通车银行信息查询
     * @param request
     * @param bankName
     * @return
     * 
     */
    @RequestMapping(value = "/queryBankCode", method = RequestMethod.POST, produces = "application/json")
    public @ResponseBody String queryBankCode(HttpServletRequest request, final String flag, final int pageNum,
            final int pageSize) {
        final Map<String, Object> anMap = Servlets.getParametersStartingWith(request, "");
        logger.info("查询支付直通车银行代码,入参：" + anMap.toString());

        return ControllerExceptionHandler.exec(new ExceptionHandler() {
            @Override
            public String handle() {
                return commissionPayBankCode.webQueryPayBankCodeInfo(anMap, flag, pageNum, pageSize);
            }
        }, "银行直通车代码查询出错！", logger);

    }

    /**
     * 
     * @Title: saveAddPayBankCodeInfo 
     * @Description: TODO(新增银行直通车代码) 
     * @param @param request
     * @param @return 参数说明 
     * @return String 返回类型 
     * @throws 
     * @author chenlq
     * @date 2017年10月23日 上午10:23:15
     */
    @RequestMapping(value = "/saveAddPayBankCodeInfo", method = RequestMethod.POST)
    public @ResponseBody String saveAddPayBankCodeInfo(HttpServletRequest request) {
        final Map<String, Object> paramMap = Servlets.getParametersStartingWith(request, "");
        logger.info("新增银行直通车代码,入参：" + paramMap.toString());
        return ControllerExceptionHandler.exec(new ExceptionHandler() {
            @Override
            public String handle() {
                return commissionPayBankCode.webSavePayBankCodeInfo(paramMap);
            }
        }, "直通车代码新增失败", logger);
    }

    /**
     * 
     * @Title: saveUpdataPayBankCodeInfo 
     * @Description: TODO(编辑直通车代码) 
     * @param @param request
     * @param @return 参数说明 
     * @return String 返回类型 
     * @throws 
     * @author chenlq
     * @date 2017年10月23日 上午10:23:41
     */
    @RequestMapping(value = "/saveUpdataPayBankCodeInfo", method = RequestMethod.POST)
    public @ResponseBody String saveUpdataPayBankCodeInfo(HttpServletRequest request) {
        final Map paramMap = Servlets.getParametersStartingWith(request, "");
        logger.info("修改银行直通车代码,入参：" + paramMap.toString());
        return ControllerExceptionHandler.exec(new ExceptionHandler() {
            @Override
            public String handle() {
                return commissionPayBankCode.webSaveUpdataBankCodeInfo(paramMap);
            }
        }, "直通车代码修改失败", logger);
    }

}
